<template>
	<view style="background-color: #f5f5f5;min-height: 100vh;">
		<headerSlotVue :propsColor="'#fff'">
			<template v-slot:header>
				<view class="header_slot flex justify-start align-center" @click="closePage()">
					<view class="action" style="margin-right: 20rpx;">
						<text class="cuIcon-back"></text>
					</view>
					<view class="content text-bold">
						订单详情
					</view>
				</view>
			</template>
		</headerSlotVue>

		<!-- 加载状态 -->
		<view class="loading-container" v-if="!orderDetail || !orderDetail._id">
			<view class="loading-content">
				<view class="loading-icon">⏳</view>
				<text class="loading-text">加载订单详情中...</text>
			</view>
		</view>

		<view class="order-detail-container" v-if="orderDetail && orderDetail._id">
			<!-- 订单状态 -->
			<view class="status-card">
				<view class="status-header">
					<text class="status-title">{{ getStatusText(orderDetail.status) }}</text>
					<text class="status-desc">{{ getStatusDesc(orderDetail.status) }}</text>
					<text class="status-sync-tip" v-if="getStatusSyncTip()">{{ getStatusSyncTip() }}</text>
				</view>
			</view>

			<!-- 订单进度 -->
			<view class="progress-card">
				<view class="progress-header">
					<text class="progress-title">订单进度</text>
				</view>
				<view class="progress-content">
					<view class="progress-bar">
						<view class="progress-fill" :style="{ width: getProgressWidth(orderDetail.status) + '%' }">
						</view>
					</view>
					<view class="progress-steps">
						<view v-for="(step, index) in getProgressSteps(orderDetail.status)" :key="index"
							class="progress-step" :class="{ 
								'completed': step.completed, 
								'current': step.current,
								'pending': !step.completed && !step.current
							}">
							<view class="step-icon">
								<text class="step-icon-text">{{step.icon}}</text>
							</view>
							<view class="step-info">
								<text class="step-text">{{step.text}}</text>
								<text class="step-time" v-if="step.time">{{step.time}}</text>
							</view>
						</view>
					</view>
				</view>
			</view>

			<!-- 收货地址 -->
			<view class="address-card" v-if="parsedAddress">
				<view class="card-header">
					<text class="card-title">收货地址</text>
				</view>
				<view class="address-content">
					<view class="address-info">
						<text class="name">{{ parsedAddress.name }}</text>
						<text class="phone">{{ parsedAddress.phone }}</text>
					</view>
					<view class="address-text">
						{{ parsedAddress.fullAddress }}
					</view>
				</view>
			</view>

			<!-- 商品信息 -->
			<view class="goods-card">
				<view class="card-header">
					<text class="card-title">商品信息</text>
				</view>
				<view class="goods-list">
					<view class="goods-item" v-for="(product, index) in orderDetail.products" :key="index">
						<view class="goods-img">
							<image :src="getProductImage(product)" mode="aspectFill"></image>
						</view>
						<view class="goods-info">
							<view class="goods-name">{{ getProductName(product) }}</view>
							<view class="goods-price">
								<text class="price">¥{{ product.price }}</text>
								<text class="quantity">x{{ product.quantity }}</text>
							</view>
						</view>
					</view>
				</view>
			</view>

			<!-- 订单信息 -->
			<view class="order-info-card">
				<view class="card-header">
					<text class="card-title">订单信息</text>
				</view>
				<view class="info-list">
					<view class="info-item">
						<text class="label">订单编号</text>
						<text class="value">{{ orderDetail.orderNo }}</text>
					</view>
					<view class="info-item">
						<text class="label">支付状态</text>
						<text class="value payment-status"
							:class="'status-' + orderDetail.payStatus">{{ orderDetail.paymentStatusText || getPayStatusText(orderDetail.payStatus) }}</text>
					</view>
					<view class="info-item">
						<text class="label">下单时间</text>
						<text class="value">{{ formatDate(orderDetail.createTime) }}</text>
					</view>
					<view class="info-item" v-if="orderDetail.payTime">
						<text class="label">支付时间</text>
						<text class="value">{{ formatDate(orderDetail.payTime) }}</text>
					</view>
					<view class="info-item" v-if="orderDetail.shipTime">
						<text class="label">发货时间</text>
						<text class="value">{{ formatDate(orderDetail.shipTime) }}</text>
					</view>
					<view class="info-item" v-if="orderDetail.deliveryTime">
						<text class="label">送达时间</text>
						<text class="value">{{ formatDate(orderDetail.deliveryTime) }}</text>
					</view>
					<view class="info-item" v-if="orderDetail.cancelTime">
						<text class="label">取消时间</text>
						<text class="value">{{ formatDate(orderDetail.cancelTime) }}</text>
					</view>
					<view class="info-item" v-if="orderDetail.status === 'cancelled' && orderDetail.refundStatus && orderDetail.payStatus === 'paid'">
						<text class="label">退款状态</text>
						<text class="value refund-status"
							:class="'refund-' + orderDetail.refundStatus">{{ getRefundStatusText(orderDetail.refundStatus) }}</text>
					</view>
					<view class="info-item" v-if="orderDetail.status === 'cancelled' && orderDetail.refundTime && orderDetail.payStatus === 'paid'">
						<text class="label">退款时间</text>
						<text class="value">{{ formatDate(orderDetail.refundTime) }}</text>
					</view>
					<!-- 帮送服务订单信息 -->
					<view class="info-item" v-if="hasRelatedDeliveryOrder">
						<text class="label">帮送服务</text>
						<text class="value delivery-status">{{ deliveryOrderStatusText }}</text>
					</view>
				</view>
			</view>

			<!-- 费用明细 -->
			<view class="fee-card">
				<view class="card-header">
					<text class="card-title">费用明细</text>
				</view>
				<view class="fee-list">
					<view class="fee-item">
						<text class="label">商品总额</text>
						<text class="value">¥{{ orderDetail.totalAmount }}</text>
					</view>
					<view class="fee-item" v-if="orderDetail.addDeliveryService">
						<text class="label">跑腿费</text>
						<text class="value">¥{{ orderDetail.deliveryServiceFee }}</text>
					</view>
					<view class="fee-item total">
						<text class="label">应付金额</text>
						<text class="value">¥{{ orderDetail.payAmount }}</text>
					</view>
					<view class="fee-item" v-if="orderDetail.actualPaidAmount > 0">
						<text class="label">实付金额</text>
						<text class="value paid-amount">¥{{ orderDetail.actualPaidAmount }}</text>
					</view>
					<view class="fee-item" v-if="orderDetail.status === 'cancelled' && orderDetail.refundAmount > 0 && orderDetail.payStatus === 'paid'">
						<text class="label">退款金额</text>
						<text class="value refund-amount">¥{{ orderDetail.refundAmount }}</text>
					</view>
				</view>
			</view>

			<!-- 支付组件 -->
			<ProductOrderPayment v-if="orderDetail.status === 'pending'" :order="orderDetail"
				@payment-success="onPaymentSuccess" @payment-error="onPaymentError" @payment-timeout="onPaymentTimeout"
				@order-cancelled="onOrderCancelled" />

			<!-- 操作按钮 -->
			<view class="action-buttons" v-if="orderDetail.status !== 'pending'">
				<button v-if="orderDetail.status === 'shipped' || orderDetail.status === 'received'"
					@click="confirmReceive" class="action-btn primary">
					确认收货
				</button>
				<!-- <button 
					v-if="orderDetail.status === 'completed'"
					@click="goToComment"
					class="action-btn secondary"
				>
					评价订单
				</button> -->
				<button v-if="orderDetail.status === 'paid' || orderDetail.status === 'pending'" @click="cancelOrder"
					class="action-btn danger">
					取消订单
				</button>
			</view>
		</view>
	</view>
</template>

<script>
	import headerSlotVue from '@/components/header-slot.vue';
	import ProductOrderPayment from '@/components/product-order-payment.vue';
	import {
		getProductOrderDetail,
		cancelProductOrder,
		receiveProductOrder
	} from '@/api/productOrder.js';

	export default {
		components: {
			headerSlotVue,
			ProductOrderPayment
		},
		data() {
			return {
				orderId: '',
				orderType: '',
				orderDetail: {
					_id: '',
					orderNo: '',
					status: '',
					payAmount: 0,
					actualPaidAmount: 0,
					totalAmount: 0,
					deliveryServiceFee: 0,
					addDeliveryService: false,
					payStatus: '',
					paymentStatusText: '',
					products: [],
					address: '',
					createTime: '',
					payTime: '',
					shipTime: '',
					deliveryTime: '',
					cancelTime: '',
					refundStatus: '', // 退款状态
					refundTime: '', // 退款时间
					refundAmount: 0 // 退款金额
				}
			};
		},
		computed: {
			parsedAddress() {
				if (!this.orderDetail.address) return null;
				try {
					return JSON.parse(this.orderDetail.address);
				} catch (error) {
					console.error('解析地址失败:', error);
					return null;
				}
			},
			// 检查是否有相关的帮送服务订单
			hasRelatedDeliveryOrder() {
				return this.orderDetail && this.orderDetail.relatedDeliveryOrder;
			},
			// 获取帮送服务订单状态文本
			deliveryOrderStatusText() {
				if (!this.hasRelatedDeliveryOrder) return '';
				const statusMap = {
					'pending': '待接单',
					'accepted': '已接单',
					'picked': '已取件',
					'delivered': '已送达',
					'completed': '已完成',
					'cancelled': '已取消'
				};
				return statusMap[this.orderDetail.relatedDeliveryOrder.status] || '未知状态';
			},
			// 获取完整的订单状态信息
			fullOrderStatus() {
				const baseStatus = this.getStatusText(this.orderDetail.status);
				if (this.hasRelatedDeliveryOrder) {
					return `${baseStatus} (帮送: ${this.deliveryOrderStatusText})`;
				}
				return baseStatus;
			}
		},
		onLoad(options) {
			this.orderId = options.id;
			this.orderType = options.type || 'product';
			this.loadOrderDetail();
		},
		onShow() {
			// 页面显示时刷新订单详情，确保状态同步
			if (this.orderId) {
				this.loadOrderDetail();
			}
		},
		methods: {
			/**
			 * 加载订单详情
			 */
			async loadOrderDetail() {
				try {
					uni.showLoading({
						title: '加载中...'
					});

					const response = await getProductOrderDetail(this.orderId);

					if (response.data.code === 200) {
						this.orderDetail = response.data.data;
						// 检查订单状态同步
						this.checkOrderStatusSync();
						// 显示状态同步通知
						this.showStatusSyncNotification();
					} else {
						uni.showToast({
							title: response.data.message || '加载失败',
							icon: 'error'
						});
					}
				} catch (error) {
					console.error('加载订单详情失败:', error);
					uni.showToast({
						title: '加载失败',
						icon: 'error'
					});
				} finally {
					uni.hideLoading();
				}
			},

			/**
			 * 获取状态文本
			 */
			getStatusText(status) {
				const statusMap = {
					'pending': '待支付',
					'paid': '已支付',
					'shipped': '已发货',
					'received': '已送达', // 新增：已送达状态
					'delivered': '已送达',
					'completed': '已完成',
					'cancelled': '已取消'
				};
				return statusMap[status] || '未知状态';
			},

			/**
			 * 获取状态描述
			 */
			getStatusDesc(status) {
				const descMap = {
					'pending': '请尽快完成支付',
					'paid': '商家正在处理您的订单',
					'shipped': '商品正在配送中',
					'received': '商品已送达，请确认收货', // 新增：已送达状态描述
					'delivered': '商品已送达，请确认收货',
					'completed': '订单已完成',
					'cancelled': '订单已取消'
				};
				return descMap[status] || '';
			},

			/**
			 * 获取支付状态文本
			 */
			getPayStatusText(payStatus) {
				const statusMap = {
					'unpaid': '未支付',
					'paid': '已支付',
					'refunded': '已退款'
				};
				return statusMap[payStatus] || '未知状态';
			},

			/**
			 * 获取退款状态文本
			 */
			getRefundStatusText(refundStatus) {
				const statusMap = {
					'pending': '退款中',
					'approved': '已退款',
					'rejected': '已拒绝',
					'cancelled': '已取消'
				};
				return statusMap[refundStatus] || '未知状态';
			},

			/**
			 * 格式化日期
			 */
			formatDate(dateString) {
				if (!dateString) return '';
				const date = new Date(dateString);
				return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}`;
			},

			/**
			 * 获取商品名称
			 */
			getProductName(product) {
				// 如果商品有productId对象且包含name，则使用它
				if (product.productId && typeof product.productId === 'object' && product.productId.name) {
					return product.productId.name;
				}
				// 否则使用productName字段
				return product.productName || '未知商品';
			},

			/**
			 * 获取商品图片
			 */
			getProductImage(product) {
				// 如果商品有productId对象且包含mainImage，则使用它
				if (product.productId && typeof product.productId === 'object' && product.productId.mainImage) {
					return product.productId.mainImage;
				}
				// 否则使用productImage字段
				return product.productImage || '/static/logo-orange.png';
			},

			/**
			 * 获取订单进度宽度
			 */
			getProgressWidth(status) {
				switch (status) {
					case 'pending':
						return 0;
					case 'paid':
						return 25;
					case 'shipped':
						return 50;
					case 'received': // 新增：已送达状态
						return 75;
					case 'delivered':
						return 75;
					case 'completed':
						return 100;
					case 'cancelled':
						// 如果有退款信息且已支付，根据退款状态计算进度
						if (this.orderDetail && this.orderDetail.payStatus === 'paid' && this.orderDetail.refundStatus) {
							switch (this.orderDetail.refundStatus) {
								case 'pending':
									return 75;
								case 'approved':
									return 100;
								case 'rejected':
								case 'cancelled':
									return 75;
								default:
									return 75;
							}
						}
						return 50; // 未支付或已支付但无退款信息的取消订单 - 完成下单和取消步骤
					default:
						return 0;
				}
			},

			/**
			 * 获取订单进度步骤
			 */
			getProgressSteps(status) {
				// 安全检查，确保orderDetail存在
				if (!this.orderDetail) {
					return [];
				}

				let steps = [{
						icon: '📝',
						text: '下单',
						completed: false,
						current: false,
						time: this.formatDate(this.orderDetail.createTime || '')
					},
					{
						icon: '💳',
						text: '支付',
						completed: false,
						current: false,
						time: this.formatDate(this.orderDetail.payTime || '')
					},
					{
						icon: '📦',
						text: '发货',
						completed: false,
						current: false,
						time: this.formatDate(this.orderDetail.shipTime || '')
					},
					{
						icon: '🚚',
						text: '送达',
						completed: false,
						current: false,
						time: this.formatDate(this.orderDetail.deliveryTime || '')
					},
					{
						icon: '✅',
						text: '完成',
						completed: false,
						current: false,
						time: ''
					}
				];

				// 如果是已取消状态，根据支付状态决定显示哪种步骤
				if (status === 'cancelled') {
					if (this.orderDetail.payStatus === 'paid' && this.orderDetail.refundStatus) {
						// 已支付且有退款信息的取消订单 - 显示退款步骤
						steps = [{
							icon: '📝',
							text: '下单',
							completed: false,
							current: false,
							time: this.formatDate(this.orderDetail.createTime || '')
						},
						{
							icon: '💳',
							text: '支付',
							completed: false,
							current: false,
							time: this.formatDate(this.orderDetail.payTime || '')
						},
						{
							icon: '❌',
							text: '取消',
							completed: false,
							current: false,
							time: this.formatDate(this.orderDetail.cancelTime || '')
						},
						{
							icon: '💰',
							text: '退款',
							completed: false,
							current: false,
							time: this.formatDate(this.orderDetail.refundTime || '')
						}
						];
					} else {
						// 未支付或已支付但无退款信息的取消订单 - 显示取消步骤
						steps = [{
							icon: '📝',
							text: '下单',
							completed: false,
							current: false,
							time: this.formatDate(this.orderDetail.createTime || '')
						},
						{
							icon: '❌',
							text: '取消',
							completed: false,
							current: false,
							time: this.formatDate(this.orderDetail.cancelTime || '')
						}
						];
					}
				}

				// 根据状态设置完成和当前状态
				switch (status) {
					case 'pending':
						steps[0].completed = true;
						steps[0].current = false;
						steps[1].current = true;
						break;
					case 'paid':
						steps[0].completed = true;
						steps[1].completed = true;
						steps[1].current = false;
						steps[2].current = true;
						break;
					case 'shipped':
						steps[0].completed = true;
						steps[1].completed = true;
						steps[2].completed = true;
						steps[2].current = false;
						steps[3].current = true;
						break;
					case 'received': // 新增：已送达状态
						steps[0].completed = true;
						steps[1].completed = true;
						steps[2].completed = true;
						steps[3].completed = true;
						steps[3].current = false;
						steps[4].current = true;
						break;
					case 'delivered':
						steps[0].completed = true;
						steps[1].completed = true;
						steps[2].completed = true;
						steps[3].completed = true;
						steps[3].current = false;
						steps[4].current = true;
						break;
					case 'completed':
						steps[0].completed = true;
						steps[1].completed = true;
						steps[2].completed = true;
						steps[3].completed = true;
						steps[4].completed = true;
						steps[4].current = false;
						break;
					case 'cancelled':
						if (this.orderDetail.payStatus === 'paid' && this.orderDetail.refundStatus) {
							// 已支付且有退款信息的取消订单 - 使用退款步骤
							steps[0].completed = true;
							steps[1].completed = true;
							steps[2].completed = true;
							steps[2].current = false;
							steps[3].current = true;

							// 根据退款状态设置退款步骤
							if (this.orderDetail.refundStatus === 'approved') {
								steps[3].completed = true;
								steps[3].current = false;
							}
						} else {
							// 未支付或已支付但无退款信息的取消订单 - 使用取消步骤
							steps[0].completed = true;
							steps[0].current = false;
							steps[1].current = true;
						}
						break;
				}

				return steps;
			},

			/**
			 * 支付成功回调
			 */
			onPaymentSuccess({
				orderId,
				result
			}) {
				uni.showToast({
					title: '支付成功！',
					icon: 'success'
				});
				// 刷新订单详情
				this.loadOrderDetail();
			},

			/**
			 * 支付失败回调
			 */
			onPaymentError({
				orderId,
				error
			}) {
				uni.showToast({
					title: '支付失败: ' + error.message,
					icon: 'none'
				});
			},

			/**
			 * 支付超时回调
			 */
			onPaymentTimeout({
				orderId
			}) {
				uni.showToast({
					title: '支付状态查询超时，请稍后手动检查',
					icon: 'none'
				});
			},

			/**
			 * 订单取消回调
			 */
			onOrderCancelled({
				orderId
			}) {
				uni.showToast({
					title: '订单已取消',
					icon: 'success'
				});
				// 刷新订单详情
				this.loadOrderDetail();
			},

			/**
			 * 确认收货
			 */
			async confirmReceive() {
				uni.showModal({
					title: '确认收货',
					content: '确认已收到商品吗？',
					success: async (res) => {
						if (res.confirm) {
							try {
								uni.showLoading({
									title: '处理中...'
								});

								// 调用确认收货API
								const response = await receiveProductOrder(this.orderId);

								uni.hideLoading();

								if (response.data.code === 200) {
									uni.showToast({
										title: '确认收货成功',
										icon: 'success'
									});
									// 刷新订单详情
									this.loadOrderDetail();
								} else {
									uni.showToast({
										title: response.data.message || '确认收货失败',
										icon: 'none'
									});
								}
							} catch (error) {
								console.error('确认收货失败:', error);
								uni.hideLoading();
								uni.showToast({
									title: '确认收货失败，请重试',
									icon: 'none'
								});
							}
						}
					}
				});
			},

			/**
			 * 检查订单状态同步
			 * 根据文档中的状态对应关系检查订单状态是否同步
			 */
			checkOrderStatusSync() {
				if (!this.orderDetail || !this.hasRelatedDeliveryOrder) {
					return;
				}

				const productOrderStatus = this.orderDetail.status;
				const deliveryOrderStatus = this.orderDetail.relatedDeliveryOrder.status;

				// 根据文档中的状态对应关系进行检查
				const expectedSync = {
					'shipped': ['pending', 'accepted', 'picked'],
					'received': ['delivered'],
					'completed': ['completed']
				};

				const expectedDeliveryStatus = expectedSync[productOrderStatus];
				if (expectedDeliveryStatus && !expectedDeliveryStatus.includes(deliveryOrderStatus)) {
					// 订单状态不同步，但不显示警告日志
				}
			},

			/**
			 * 获取订单状态同步提示信息
			 */
			getStatusSyncTip() {
				if (!this.hasRelatedDeliveryOrder) {
					return '';
				}

				const productOrderStatus = this.orderDetail.status;
				const deliveryOrderStatus = this.orderDetail.relatedDeliveryOrder.status;

				// 根据文档中的状态对应关系生成提示信息
				const syncTips = {
					'shipped': {
						'pending': '帮送订单待接单中',
						'accepted': '帮送订单已接单，正在取件',
						'picked': '帮送订单已取件，正在配送'
					},
					'received': {
						'delivered': '帮送订单已送达，请确认收货'
					},
					'completed': {
						'completed': '帮送订单已完成'
					}
				};

				return syncTips[productOrderStatus]?.[deliveryOrderStatus] || '';
			},

			/**
			 * 显示订单状态同步通知
			 */
			showStatusSyncNotification() {
				if (!this.hasRelatedDeliveryOrder) {
					return;
				}

				const productOrderStatus = this.orderDetail.status;
				const deliveryOrderStatus = this.orderDetail.relatedDeliveryOrder.status;

				// 根据状态变更显示相应的通知
				if (productOrderStatus === 'received' && deliveryOrderStatus === 'delivered') {
					uni.showToast({
						title: '帮送订单已送达，请确认收货',
						icon: 'none',
						duration: 3000
					});
				} else if (productOrderStatus === 'completed' && deliveryOrderStatus === 'completed') {
					uni.showToast({
						title: '订单已完成，帮送服务已结算',
						icon: 'success',
						duration: 2000
					});
				}
			},

			/**
			 * 刷新订单状态
			 * 用于实时更新订单状态信息
			 */
			async refreshOrderStatus() {
				try {
					const response = await getProductOrderDetail(this.orderId);
					if (response.data.code === 200) {
						const newOrderDetail = response.data.data;
						const oldStatus = this.orderDetail.status;
						const newStatus = newOrderDetail.status;

						// 更新订单详情
						this.orderDetail = newOrderDetail;

						// 检查状态是否发生变化
						if (oldStatus !== newStatus) {
							// 状态发生变化，显示通知
							this.showStatusSyncNotification();
						}

						// 检查订单状态同步
						this.checkOrderStatusSync();
					}
				} catch (error) {
					// 刷新订单状态失败，静默处理
				}
			},

			/**
			 * 去评价
			 */
			goToComment() {
				this.$router.smartNavigate({
					url: `/pages/mePages/orderComment?id=${this.orderId}`
				});
			},

			/**
			 * 取消订单
			 */
			cancelOrder() {
				uni.showModal({
					title: '取消订单',
					content: '确定要取消这个订单吗？',
					success: async (res) => {
						if (res.confirm) {
							try {
								uni.showLoading({
									title: '取消中...'
								});

								await cancelProductOrder(this.orderId, '用户主动取消');

								uni.hideLoading();
								uni.showToast({
									title: '订单已取消',
									icon: 'success'
								});

								this.loadOrderDetail();
							} catch (error) {
								console.error('取消订单失败:', error);
								uni.hideLoading();
								uni.showToast({
									title: '取消订单失败',
									icon: 'error'
								});
							}
						}
					}
				});
			},

			/**
			 * 关闭页面
			 */
			closePage() {
				uni.navigateBack();
			}
		}
	};
</script>

<style lang="scss" scoped>
	.order-detail-container {
		padding: 20rpx;
	}

	.status-card {
		background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
		border-radius: 16rpx;
		padding: 40rpx 30rpx;
		margin-bottom: 20rpx;
		color: white;

		.status-header {
			.status-title {
				font-size: 36rpx;
				font-weight: bold;
				display: block;
				margin-bottom: 10rpx;
			}

			.status-desc {
				font-size: 28rpx;
				opacity: 0.9;
			}

			.status-sync-tip {
				font-size: 24rpx;
				opacity: 0.8;
				margin-top: 8rpx;
				display: block;
				color: #ffd700;
			}
		}
	}

	.progress-card {
		background: white;
		border-radius: 16rpx;
		padding: 30rpx;
		margin-bottom: 20rpx;
		box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);

		.progress-header {
			margin-bottom: 30rpx;

			.progress-title {
				font-size: 32rpx;
				font-weight: bold;
				color: #333;
			}
		}

		.progress-content {
			.progress-bar {
				height: 12rpx;
				background-color: #f0f0f0;
				border-radius: 6rpx;
				margin-bottom: 30rpx;
				overflow: hidden;
				position: relative;

				.progress-fill {
					height: 100%;
					background: linear-gradient(90deg, #FE6100, #FF8C42);
					border-radius: 6rpx;
					transition: width 0.5s ease-in-out;
					position: relative;

					&::after {
						content: '';
						position: absolute;
						top: 0;
						left: 0;
						right: 0;
						bottom: 0;
						background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
						animation: shimmer 2s infinite;
					}
				}
			}

			.progress-steps {
				display: flex;
				justify-content: space-between;
				align-items: flex-start;
				position: relative;

				.progress-step {
					display: flex;
					flex-direction: column;
					align-items: center;
					flex: 1;
					position: relative;
					z-index: 2;

					&:not(:last-child)::after {
						content: '';
						position: absolute;
						top: 40rpx;
						left: 50%;
						width: calc(100% - 60rpx);
						height: 2rpx;
						background-color: #e0e0e0;
						z-index: 1;
					}

					&.completed {
						&:not(:last-child)::after {
							background-color: #FE6100;
						}

						.step-icon {
							background: linear-gradient(135deg, #52c41a, #73d13d);
							box-shadow: 0 4rpx 12rpx rgba(82, 196, 26, 0.3);
						}

						.step-icon-text {
							color: white;
						}

						.step-text {
							color: #52c41a;
							font-weight: 600;
						}
					}

					&.current {
						.step-icon {
							background: linear-gradient(135deg, #FE6100, #FF8C42);
							box-shadow: 0 4rpx 12rpx rgba(254, 97, 0, 0.3);
							animation: pulse 2s infinite;
						}

						.step-icon-text {
							color: white;
						}

						.step-text {
							color: #FE6100;
							font-weight: 600;
						}
					}

					&.pending {
						.step-icon {
							background-color: #f5f5f5;
							border: 2rpx solid #e0e0e0;
						}

						.step-icon-text {
							color: #999;
						}

						.step-text {
							color: #999;
						}
					}

					.step-icon {
						width: 80rpx;
						height: 80rpx;
						border-radius: 50%;
						display: flex;
						justify-content: center;
						align-items: center;
						margin-bottom: 16rpx;
						position: relative;
						z-index: 3;

						.step-icon-text {
							font-size: 36rpx;
						}
					}

					.step-info {
						text-align: center;

						.step-text {
							font-size: 26rpx;
							margin-bottom: 8rpx;
							display: block;
						}

						.step-time {
							font-size: 22rpx;
							color: #999;
							display: block;
						}
					}
				}
			}
		}
	}

	@keyframes shimmer {
		0% {
			transform: translateX(-100%);
		}

		100% {
			transform: translateX(100%);
		}
	}

	@keyframes pulse {

		0%,
		100% {
			transform: scale(1);
		}

		50% {
			transform: scale(1.05);
		}
	}

	.address-card,
	.goods-card,
	.order-info-card,
	.fee-card {
		background: white;
		border-radius: 16rpx;
		padding: 30rpx;
		margin-bottom: 20rpx;

		.card-header {
			margin-bottom: 20rpx;

			.card-title {
				font-size: 32rpx;
				font-weight: bold;
				color: #333;
			}
		}
	}

	.address-content {
		.address-info {
			margin-bottom: 10rpx;

			.name {
				font-size: 30rpx;
				font-weight: bold;
				margin-right: 20rpx;
			}

			.phone {
				font-size: 28rpx;
				color: #666;
			}
		}

		.address-text {
			font-size: 28rpx;
			color: #333;
			line-height: 1.5;
		}
	}

	.goods-list {
		.goods-item {
			display: flex;
			padding: 20rpx 0;
			border-bottom: 1rpx solid #f5f5f5;

			&:last-child {
				border-bottom: none;
			}

			.goods-img {
				width: 120rpx;
				height: 120rpx;
				margin-right: 20rpx;

				image {
					width: 100%;
					height: 100%;
					border-radius: 12rpx;
				}
			}

			.goods-info {
				flex: 1;

				.goods-name {
					font-size: 28rpx;
					color: #333;
					margin-bottom: 10rpx;
					line-height: 1.4;
				}

				.goods-price {
					display: flex;
					justify-content: space-between;
					align-items: center;

					.price {
						font-size: 30rpx;
						color: #ff4757;
						font-weight: bold;
					}

					.quantity {
						font-size: 26rpx;
						color: #666;
					}
				}
			}
		}
	}

	.info-list,
	.fee-list {

		.info-item,
		.fee-item {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 16rpx 0;
			border-bottom: 1rpx solid #f5f5f5;

			&:last-child {
				border-bottom: none;
			}

			&.total {
				border-top: 2rpx solid #f0f0f0;
				margin-top: 10rpx;
				padding-top: 20rpx;

				.label,
				.value {
					font-weight: bold;
					font-size: 32rpx;
				}

				.value {
					color: #ff4757;

					&.paid-amount {
						color: #2ed573;
						font-weight: bold;
					}

					&.refund-amount {
						color: #ff4757;
						font-weight: bold;
					}
				}
			}

			.label {
				font-size: 28rpx;
				color: #666;
			}

			.value {
				font-size: 28rpx;
				color: #333;

				&.payment-status {
					&.status-unpaid {
						color: #ffa502;
					}

					&.status-paid {
						color: #2ed573;
					}

					&.status-refunded {
						color: #ff4757;
					}
				}

				&.refund-status {
					&.refund-pending {
						color: #ffa502;
					}

					&.refund-approved {
						color: #2ed573;
					}

					&.refund-rejected {
						color: #ff4757;
					}

					&.refund-cancelled {
						color: #999;
					}
				}

				&.delivery-status {
					color: #1890ff;
					font-weight: 600;
				}
			}
		}
	}

	.action-buttons {
		display: flex;
		gap: 20rpx;
		padding: 20rpx;
		background: white;
		border-radius: 16rpx;
		margin-top: 20rpx;

		.action-btn {
			flex: 1;
			height: 80rpx;
			border-radius: 12rpx;
			font-size: 28rpx;
			font-weight: bold;
			border: none;

			&.primary {
				background-color: #1890ff;
				color: white;
			}

			&.secondary {
				background-color: #52c41a;
				color: white;
			}

			&.danger {
				background-color: #ff4757;
				color: white;
			}
		}
	}

	.header_slot {
		padding: 0 32rpx;
		width: 100%;
		font-weight: 500;
		font-size: 36rpx;
		color: #2C2622;
	}

	.loading-container {
		display: flex;
		justify-content: center;
		align-items: center;
		height: 100vh;
		background-color: #f5f5f5;

		.loading-content {
			display: flex;
			flex-direction: column;
			align-items: center;
			padding: 40rpx;
			background-color: white;
			border-radius: 16rpx;
			box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);

			.loading-icon {
				font-size: 80rpx;
				margin-bottom: 20rpx;
			}

			.loading-text {
				font-size: 32rpx;
				color: #666;
			}
		}
	}
</style>